import mydb from "../db";
import {IpcChannel} from "../ipc";

export function useDbHandle() {
	return {
		[IpcChannel.SqlRun]: async (event, args) => {
			let sql = args.sql,
				params = args.params || [];
			try {
				return await mydb.run(sql, params);
			} catch (error) {
				console.error(error);
				return false;
			}
		},
	};
}
